var t = getApp();

Page({
    data: {
        infoData: {},
        show: !1,
        is_Poster: ""
    },
    onLoad: function(t) {
        this.getData();
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    gotoGroupBuying: function() {
        wx.navigateTo({
            url: "/packageE/community_buying/group_buying/group_buying"
        });
    },
    gotoMyInfo: function() {
        wx.navigateTo({
            url: "/packageE/community_buying/edit_info/edit_info"
        });
    },
    gotoOrder: function() {
        wx.navigateTo({
            url: "/packageE/community_buying/buying_order/buying_order"
        });
    },
    gotoReward: function() {
        wx.navigateTo({
            url: "/packageC/selfCarry/selfCarry_reward/selfCarry_reward"
        });
    },
    onReachBottom: function() {},
    preview: function(t) {
        wx.previewImage({
            current: this.data.is_Poster,
            urls: []
        });
    },
    saveImg: function() {
        wx.getSetting({
            success: function(t) {
                t.authSetting["scope.writePhotosAlbum"] || wx.authorize({
                    scope: "scope.writePhotosAlbum",
                    success: function() {
                        console.log("授权成功");
                    }
                });
            }
        });
        var t = this.data.is_Poster;
        wx.downloadFile({
            url: t,
            success: function(t) {
                wx.saveImageToPhotosAlbum({
                    filePath: t.tempFilePath,
                    success: function(t) {
                        wx.showToast({
                            title: "保存成功",
                            icon: "none",
                            duration: 2e3
                        });
                    },
                    fail: function(t) {
                        "saveImageToPhotosAlbum:fail auth deny" === t.errMsg && (console.log("当初用户拒绝，再次发起授权"), 
                        wx.openSetting({
                            success: function(t) {
                                t.authSetting["scope.writePhotosAlbum"] ? wx.showToast({
                                    icon: "none",
                                    title: "获取权限成功,再次长按保存图片",
                                    duration: 1500
                                }) : wx.showToast({
                                    icon: "none",
                                    title: "获取权限失败,保存图片需要用户授权",
                                    duration: 1500
                                });
                            }
                        }));
                    },
                    complete: function(t) {
                        console.log(t);
                    }
                });
            }
        });
    },
    onCopy: function() {
        wx.setClipboardData({
            data: "/packageF/others/deliverPoster/deliverPoster?id=" + this.data.infoData.deliver_id,
            success: function(t) {
                wx.showToast({
                    icon: "none",
                    title: "复制成功",
                    duration: 1e3
                });
            }
        });
    },
    onClose: function() {
        this.setData({
            show: !1
        });
    },
    getposter: function() {
        var e = this, o = t.getNetAddresss("plugin.package-deliver.frontend.deliver-share.getPoster");
        t._postNetWork({
            url: o,
            data: {
                deliver_id: this.data.infoData.deliver_id
            },
            success: function(t) {
                var o = t.data;
                1 == o.result && e.setData({
                    is_Poster: o.data.url,
                    show: !0
                });
            }
        });
    },
    getData: function() {
        var e = this, o = t.getNetAddresss("plugin.package-deliver.frontend.deliver.getDeliverBonusAmount");
        t._postNetWork({
            url: o,
            success: function(t) {
                var o = t.data;
                1 == o.result && e.setData({
                    infoData: o.data
                });
            }
        });
    },
    onShareAppMessage: function() {}
});